export const city = (state = {}, action) => {
    switch (action.type) {
        case "initCity":
            return action.data;
        case "setCity":
            return action.data;
        default:
            return state
    }
}
export const user = (state = { isLogin: false, loading: false, error: "" }, action) => {
    switch (action.type) {
        case "logining":
            return {
                ...state,
                loading: true,
                isLogin: false,
            }
        case "loginSuccess":
            return {
                ...state,
                isLogin: true,
                loading: false
            };
        case "loginError":
            return {
                ...state,
                error: action.err,
                loading: false
            }
        default:
            return state
    }
}


export const collection = (state = [], action) => {
    switch (action.type) {
        case "addCollection":

            state.push(action.data);
            return state

        case "removeCollection":
            return state.filter(element => {
                return element != action.data
            })
        default:
            return state
    }
}

export const order = (state = [], action) => {
    switch (action.type) {
        case "getOrder":
            return action.data;
        default:
            return state
    }
}

export const recomment = (state = [], action) => {
    switch (action.type) {
        case "addComment":
            state.push(action.data)
            return state
        default:
            return state
    }

}